package game.ability;

import java.util.ArrayList;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class AbilityManager {

	ArrayList<AbsAbility> abilities;

	public void add(AbsAbility ability) {
		abilities.add(ability);
	}

	public void remove(int abilityID) {
		for (int i = 0; i < abilities.size(); i++)
			if (abilities.get(i).getId() == abilityID)
				abilities.remove(i);
	}

	public AbilityManager() {
		abilities = new ArrayList<AbsAbility>();
	}

	public void update() {
		for (int i = 0; i < abilities.size(); i++) {
			if((abilities.size()>0)&&(i<abilities.size()))
				abilities.get(i).update();
			if (abilities.get(i).complete)
				abilities.remove(i);
		}
	}

	public void render(SpriteBatch sb) {
		for (int i = 0; i < abilities.size(); i++)
			abilities.get(i).render(sb);
	}
	
	public void render(int abilityID, SpriteBatch sb) {
		for (int i = 0; i < abilities.size(); i++)
			if (abilities.get(i).id == abilityID)
				abilities.get(i).render(sb);
	}
	
	
	public void renderShape() {
		for (int i = 0; i < abilities.size(); i++)
			abilities.get(i).renderShape();
	}

	public void action(int abilityID) {

		for (int i = 0; i < abilities.size(); i++)
			if (abilities.get(i).id == abilityID)
				abilities.get(i).action();
	}
	public void setSlower(float slower)
	{
		for (AbsAbility ability : abilities) {
			ability.setSlower(slower);
		}
	}
}
